<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script src="./js/jquery-3.3.1.min.js"></script>
  <title>Document</title>
</head>
<body>
  <div>
    <input type="text" id="first">
    <select>
      <option value="">请选择</option>
      <option value="add">+</option>
      <option value="sub">-</option>
      <option value="mult">*</option>
      <option value="divi">/</option>
    </select>
    <input type="text" id="second">
    <input type="button" value="=">
    <input type="text" id="sum">
  </div>
  <script>
    var sum;
    $("input:button").click(function() {
      var first = $("#first").val();
      var second = $("#second").val();
      var opea = $("option:selected").val();
      if(first && second) {
        switch (opea) {
          case "add":
            sum = first + second;
            break;
          case "sub":
            sum = first - second;
            break;
          case "mult":
            sum = first * second;
            break;
          case "divi":
            if (second == 0) {
              alert("除数不能为0，请重新输入！");
            } else {
              sum = first / second;
            }
            break;
          default:
            alert("请选择操作符！");
            break;
        }
        $("#sum").val(sum);
      } else {
        alert("请输入数值");
      } 
    })
  </script>
</body>
</html>